//
//  ChainNewsInfo.m
//  Chain
//
//  Created by zhaosh on 2018/4/3.
//  Copyright © 2018年 zhaosh. All rights reserved.
//
#import "ChainNewsInfo.h"

@implementation ChainNewsInfo

+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper{
    return @{
             @"createTime":@[@"orderTime",@"createTime"],
             @"createUser":@[@"auther",@"createUser"],
             @"newsUrl":@[@"href",@"newsUrl"],
             @"newsCaption":@[@"title",@"newsCaption"],
             @"newsId":@[@"code",@"newsId"],
             @"newsSource":@[@"auther",@"newsSource"],
             @"type":@"type"
             };
}


-(void)setListImgArray:(NSArray *)listImgArray{
    NSMutableArray *imgArr = [NSMutableArray new];
    for (NSDictionary *kImgDic in listImgArray) {
        NSString *url = kImgDic[@"url"];
        [url stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [imgArr addObject:url];
    }
    _listImgArray = [NSArray arrayWithArray:imgArr];
}

//将时间戳转换过为时间字符串
-(void)setCreateTime:(NSString *)createTime{
    _createTime = [Datetime dealTimeDifference:createTime];
    //    _createTime = [Datetime dateStringWithtimeSp:createTime DateFormat:@"YYYY/MM/dd"];
}

-(void)setImgmd5:(NSString *)imgmd5{
    NSString *imgStr;
    NSString *imgmd5Str = [NSString stringWithFormat:@"%@",imgmd5];
    if (imgmd5 && imgmd5Str.length > 0) {
        imgStr = [NSString stringWithFormat:@"http://static.galaxyinternet.com/img/news/%@.PNG",[NSString stringWithFormat:@"%@",imgmd5]];
    }
    if (imgStr) {
        self.listImgArray = @[
                              @{@"url":imgStr}
                              ];
    }
    _imgmd5 = imgmd5;
}

-(void)setNewsCaption:(NSString *)newsCaption{
    _newsCaption = [newsCaption stringByStrippingHTML];
}

-(NSString *)isShowBigImg{
    return @"0";
}
@end
